package com.chihihx.launcher.ui.fragment

import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import com.chihihx.launcher.BaseWallPaperFragment
import com.chihihx.launcher.MainActivity
import com.chihihx.launcher.bean.DateSettingDto
import com.nova.android.tvlauncher.R
import com.nova.android.tvlauncher.databinding.FragmentSplashHxtvBinding
import com.nova.android.tvlauncher.databinding.FragmentWallpaperHxtvBinding
import com.nova.android.tvlauncher.databinding.ItemDateSettingBinding
import com.nova.android.tvlauncher.databinding.ItemWallpaperBinding
import com.nova.android.tvlauncher.ext.scaleAnimation
import com_github_lib_base.base.BaseViewModel
import com_github_lib_base.ext.replaceChildFragment
import com_github_lib_base.ext.rv.addModels
import com_github_lib_base.ext.rv.setup
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class WallPaperFragment : BaseWallPaperFragment<FragmentWallpaperHxtvBinding, BaseViewModel>() {

    override fun initView() {
        mBind.rvWallpaper.setNumColumns(3)
        mBind.rvWallpaper.setup(mutableListOf()) {
            addType(Int::class, R.layout.item_wallpaper)
            onBind {
                val itemBinding = getBinding<ItemWallpaperBinding>()
                val item = getModel<Int>()
                itemBinding.ivBigicon.setImageResource(item)
                itemView.setOnFocusChangeListener { _, hasFocus ->
                    itemView.scaleAnimation(hasFocus)
                }

            }
        }
        val list = mutableListOf<Int>(
            R.drawable.bg_launcher_default_5_7_1080,
            R.drawable.bg_launcher_default_5_7_1080,
            R.drawable.bg_launcher_default_5_7_1080,
            R.drawable.bg_launcher_default_5_7_1080,
        )
        mBind.rvWallpaper.addModels(list)
        mBind.rvWallpaper.requestFocus()

    }
}